package wanbang.controller;

import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import wanbang.entities.User;
import wanbang.service.LoginService;
@SessionAttributes(types= {User.class})
@Controller
public class LoginController {
	@Autowired
	private  LoginService loginService;
	
	
	@RequestMapping("/login")
	public 	String login(String userName, String userPassword ,Map<String,Object> map) {
		
		User user = loginService.selectByUserNameAndPassword(userName, userPassword);
		if(user!=null) {
			map.put("user", user);
			return "redirect:/BuyBook.jsp";
		}
		return "redirect:/Login.jsp";
	}
}
